<template>
  <div class="app">
    <van-nav-bar
      v-if="isShow"
      :title="title"
      left-text=""
      right-text="按钮"
      left-arrow
      @click-left="onClickLeft"
    >
      <template #right>
        <van-icon name="search" size="20" color="#666" />
      </template>
    </van-nav-bar>
    <router-view></router-view>
    <van-tabbar v-model="active" class="foot">
      <van-tabbar-item icon="home-o" to="/home">首页</van-tabbar-item>
      <van-tabbar-item icon="apps-o" to="/sort">分类</van-tabbar-item>
      <van-tabbar-item icon="cart" to="/cart">购物车</van-tabbar-item>
      <van-tabbar-item icon="manager-o" to="/me">个人</van-tabbar-item>
    </van-tabbar>
    <!-- cart中把商品加入购物车时最下面的变化 -->
    <!--已 display:none 隐藏 -->
    <van-tabbar class="gwc">
      <div class="cart-foot">
        <div class="f1">
          <div class="f1-zi">共1件 金额：</div>
          <span class="f1-price">7999</span>
          <span class="f1-tb">元</span>
        </div>
        <div class="btn1">
          <span>继续购物</span>
        </div>
        <div class="btn2">
          <span>去结算</span>
        </div>
      </div>
    </van-tabbar>
  </div>
</template>
<script>
export default {
  data: () => ({
    title: sessionStorage.title || '首页',
    active: Number(sessionStorage.active) || 0,
    isShow: false
  }),
  methods: {
    onClickLeft() {
      this.$router.go(-1)
    }
  },
  watch: {
    '$route.meta'(meta) {
      this.title = meta.title
      this.active = meta.active
      this.isShow = meta.isshow
      sessionStorage.title = meta.title
      sessionStorage.active = meta.active
    }
  }
}
</script>
<style lang="less">
.app {
  padding-bottom: 50px;
  .van-nav-bar {
    height: 50px;
    background: #f2f2f2;
    .van-nav-bar__left {
      .van-icon {
        color: #666;
      }
    }
    .van-nav-bar__title {
      color: #666;
      font-size: 18px;
      font-weight: 500;
    }
  }
  .foot {
    width: 100%;
  }
  .gwc {
    display: none;
    .cart-foot {
      height: 50px;
      width: 100%;
      display: flex;
      .f1 {
        width: 125px;
        text-align: center;
        .f1-zi {
          font-size: 12px;
          color: #999;
        }
        .f1-price {
          color: #ff5722;
          font-size: 24px;
          font-weight: bold;
        }
        .f1-tb {
          font-size: 14px;
          color: #999;
        }
      }
      .btn1 {
        width: 125px;
        background: #f4f4f4;
        span {
          line-height: 50px;
          text-align: center;
          display: block;
          color: #333;
          font-size: 14px;
        }
      }
      .btn2 {
        width: 125px;
        background: #ff6700;
        span {
          line-height: 50px;
          text-align: center;
          display: block;
          color: #fff;
          font-size: 14px;
        }
      }
    }
  }
}
</style>
